function query2Dict (param: any) {
  let pattern = /([^?&=]+)=([^&#]*)/g
  let dict: any = {}
  let search = null
  if (typeof param === 'object' && param instanceof Location) {
    search = param.search
  } else if (typeof param === 'string') {
    search = param
  } else {
    throw new Error('参数类型非法！请传入window.loaction对象或者url字符串。')
  }
  search.replace(pattern, function (rs, $1, $2) {
    let key = decodeURIComponent($1)
    let value = decodeURIComponent($2)
    dict[key] = value
    return rs
  })
  return dict
}

export {
    query2Dict
  }
